function drawResult(serial,trace) {
    const canvas = document.getElementById('myCanvas');
    const ctx = canvas.getContext('2d');

    const numCircles = serial.length;
    const canvasMinSize = Math.min(canvas.width, canvas.height);
    const maxHalfRegion = (canvasMinSize - 10) / 2;
    //const outerRadius = 100;
    const outerRadius = maxHalfRegion / 1.3;
    //const innerRadius = 15;
    const innerRadius = Math.round(0.15 * outerRadius);
    const centerX = canvas.width / 2;
    const centerY = canvas.height / 2;
    const ctxFont = (innerRadius*2).toString() + 'px Arial'

    ctx.clearRect(0, 0, canvas.width, canvas.height);    
    for (let i = 0; i < numCircles; i++) {
        const angle = (2 * Math.PI / numCircles) * i;
        const x = centerX + outerRadius * Math.cos(angle - Math.PI / 2); // Adjust angle to start at 12 o'clock
        const y = centerY + outerRadius * Math.sin(angle - Math.PI / 2);

        ctx.beginPath();
        ctx.arc(x, y, innerRadius, 0, 2 * Math.PI);

        if (serial[i] === '1') {
            ctx.fillStyle = 'red';
            ctx.fill();
        } else {
            ctx.strokeStyle = 'black';
            ctx.stroke();
        }
    }
    if(trace){
        let step = 1;
        for (let i = 0; i < trace.length; i++) {
            if(trace[i].actionDesc == ""){
                continue;
            }
            let action = parseInt(trace[i].actionDesc) + 1;
            action %= numCircles;
            const angle = (2 * Math.PI / numCircles) * action;
            const x = centerX + (outerRadius + innerRadius) * Math.cos(angle - Math.PI / 2); // Adjust angle to start at 12 o'clock
            const y = centerY + (outerRadius + innerRadius) * Math.sin(angle - Math.PI / 2);
            //ctx.font = '24px Arial'; // 设置字体大小和字体族
            ctx.font = ctxFont; // 设置字体大小和字体族
            ctx.fillStyle = 'blue'; // 设置文本颜色
            ctx.fillText(step.toString(), x, y);
            step ++;
        }
    }else{
        ctx.font = '24px Arial'; // 设置字体大小和字体族
        ctx.fillStyle = 'blue'; // 设置文本颜色
        ctx.fillText('无解', 20, 20);
    }
}
